// 文件路径: user-module/src/main/java/org/x/user/controller/RegisterController.java
package org.x.user.controller;

import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.x.common.config.Result;
import org.x.user.dto.*;
import org.x.user.service.RegisterService;

@RestController
@RequestMapping("/api")
public class RegisterController {

    @Autowired
    private RegisterService registerService;

    /**
     * 公众注册
     */
    @PostMapping("/pub/register")
    public Result publicRegister(@RequestBody @Valid PublicRegisterDTO publicRegisterDTO) {
        return registerService.publicRegister(publicRegisterDTO);
    }

    /**
     * 律师注册
     */
    @PostMapping("/lawyer/register")
    public Result lawyerRegister(@ModelAttribute LawyerRegisterDTO lawyerRegisterDTO) {
        return registerService.lawyerRegister(lawyerRegisterDTO);
    }

    /**
     * 管理员创建
     */
    @PostMapping("/admin/create")
    public Result adminCreate(@RequestBody @Valid AdminCreateDTO adminCreateDTO) {
        return registerService.adminCreate(adminCreateDTO);
    }

    /**
     * 发送短信验证码
     */
    @PostMapping("/sms/send")
    public Result sendSmsCode(@RequestBody @Valid SmsSendDTO smsSendDTO) {
        return registerService.sendSmsCode(smsSendDTO);
    }

    /**
     * 手机号校验
     */
    @PostMapping("/phone/check")
    public Result checkPhone(@RequestBody @Valid PhoneCheckDTO phoneCheckDTO) {
        return registerService.checkPhone(phoneCheckDTO);
    }

    /**
     * 获取注册协议
     */
    @GetMapping("/agreement")
    public Result getAgreement() {
        return registerService.getAgreement();
    }
}
